<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>巡检设备变更申请</title>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
$(function(){
	if($("input[name='reqReasonType']:checked").val() != '<%=StaticValue.DIC_REQ_REASON_OTHERS%>'){
		$("textarea[name='reqOtherReason']").attr("disabled","disabled");
	}
	$("input[name='reqReasonType']").click(function(){
		if($(this).val() == '<%=StaticValue.DIC_REQ_REASON_OTHERS%>'){
			$("textarea[name='reqOtherReason']").removeAttr("disabled").attr({"datatype":"*","nullmsg":"请填写其它原因","errormsg":"请填写其它原因"});
		}else{
			$("textarea[name='reqOtherReason']").attr("disabled","disabled").removeAttr("datatype").removeClass("Validform_error");
			$("textarea[name='reqOtherReason']").siblings(".Validform_checktip").removeClass("Validform_wrong").html("");
		}
	});
	$("#searchIpByPlanId").click(searchIpByPlanId);

	if($("input[name='changeType']").val() === '<%=StaticValue.DIC_EQ_CHANGE_TYPE_ADD%>'){
		$("#planId").removeAttr("datatype");
	}
	changeTypeOnChange($("input[name='changeType']:checked").val());
	$("input[name='changeType']").change(function(){
		changeTypeOnChange($(this).val());
	});
	function changeTypeOnChange(em_val){
		if(em_val === '<%=StaticValue.DIC_EQ_CHANGE_TYPE_ADD%>'){
			$("#searchIpByPlanId").unbind('click').hide();
			$("#planId").removeAttr("datatype").attr("readonly","readonly").css("background-color","#ebebe4").val("").siblings(".Validform_checktip").html("").removeClass("Validform_wrong");
			$("#equipmentSpareSn").attr("datatype","*").removeAttr("readonly placeholder").css("background-color","white").val("");
			$("#zyCinemaId").attr("datatype","*").removeAttr("readonly").css("background-color","white").val("");
			$("#zyCinemaName").attr("datatype","*").removeAttr("placeholder").css("background-color","white").val("");
			$("#zyCinemaName").siblings(".easyui-linkbutton").show();
		}else{
			$("#searchIpByPlanId").click(searchIpByPlanId).show();
			$("#planId").attr("datatype","*").removeAttr("readonly").css("background-color","white");
			$("#equipmentSpareSn").removeAttr("datatype").attr({"readonly":"readonly","placeholder":"查询后自动填充"}).val("").siblings(".Validform_checktip").html("").removeClass("Validform_wrong");
			$("#zyCinemaId").removeAttr("datatype").attr("readonly","readonly").val("");
			$("#zyCinemaName").removeAttr("datatype").attr({"readonly":"readonly","placeholder":"查询后自动填充"}).val("").siblings(".Validform_checktip").html("").removeClass("Validform_wrong");
			$("#zyCinemaName").siblings(".easyui-linkbutton").hide();
		}
	}
});
var planIdHadRecord = false;
function searchIpByPlanId(){
	/**
	 * 根据PlanId查询设备SN 和 影院名称
	 */
	var planId = $("#planId").val();
	if(planId == ''){
		tip("请输入巡检计划ID");
		return;
	}
	$.ajax({
		url : "zyEquipmentChangeController.do?queryIpInfoByPlanId",
		data : {
			"planId" : planId,
		},
		cache : false,
		dataType : 'json',
		type : 'POST',
		success : function(data){
			var rsData = data.attributes;
			if(data.success){
				planIdHadRecord = true;
				$("#equipmentSpareSn").val(rsData.esSn);
				$("#zyCinemaId").val(rsData.cmId);
				$("#zyCinemaName").val(rsData.cmName);
			}else{
				tip(data.msg);
			}
		}
	});
}

function beforeSubmit(){
	var flag = true;
	if($("input[name='changeType']:checked").val() != '<%=StaticValue.DIC_EQ_CHANGE_TYPE_ADD%>' && !planIdHadRecord){
		tip("请查询后重新提交");
		flag = false;
	}
	return flag;
}

</script>
</head>
<body>
<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="zyEquipmentChangeController.do?doAdd" tiptype="3" beforeSubmit="beforeSubmit" >
	<input id="id" name="id" type="hidden" value="${zyEquipmentChangePage.id }">
	<table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
		<tr>
			<td align="right">
				<label class="Validform_label">
					变更类型:
				</label>
			</td>
			<td class="value">
				<t:dictSelect field="changeType" type="radio" typeGroupCode="<%=StaticValue.DIC_EQ_CHANGE_TYPE %>" />
				<span class="Validform_checktip"></span>
				<label class="Validform_label" style="display: none;">变更类型</label>
			</td>
		</tr>
		<tr>
			<td align="right">
				<label class="Validform_label">
					巡检计划ID:
				</label>
			</td>
			<td class="value">
				<input id="planId" name="planId" type="text" style="width: 150px" class="inputxt" datatype="*" /><a class="easyui-linkbutton" plain="true" icon="icon-search" id="searchIpByPlanId">查询</a>
				<span class="Validform_checktip"></span>
				<label class="Validform_label" style="display: none;">巡检计划ID</label>
			</td>
		</tr>
		<tr>
			<td align="right">
				<label class="Validform_label">
					设备SN:
				</label>
			</td>
			<td class="value">
				<input id="equipmentSpareSn" name="equipmentSpareSn" type="text" style="width: 150px" class="inputxt" datatype="*" />
				<span class="Validform_checktip"></span>
				<label class="Validform_label" style="display: none;">设备SN</label>
			</td>
		</tr>
		<tr>
			<td align="right">
				<label class="Validform_label">
					影院名称:
				</label>
			</td>
			<td class="value">
				<input name="zyCinema.id" type="hidden" id="zyCinemaId">
                <input name="cinemaName" class="inputxt" id="zyCinemaName" readonly="readonly" datatype="*" />
                <t:choose hiddenName="zyCinemaId" hiddenid="id" url="zyEquipmentChangeController.do?zyChooseCinemasForEsChange" name="cinemaList"
                          icon="icon-search" title="影院列表" textname="name" inputTextname="zyCinemaName" isclear="true"></t:choose>
				<span class="Validform_checktip"></span>
				<label class="Validform_label" style="display: none;">影院名称</label>
			</td>
		</tr>
		<tr>
			<td align="right">
				<label class="Validform_label">
				原因
				</label>
			</td>
			<td class="value">
				<t:dictSelect field="reqReasonType" type="radio" typeGroupCode="<%=StaticValue.DIC_REQ_REASON %>" />
				<span class="Validform_checktip"></span>
				<label class="Validform_label" style="display: none;">原因</label>
			</td>
		</tr>
		<tr>
			<td align="right">
			</td>
			<td class="value">
				<textarea rows="5" cols="60" name="reqOtherReason" nullmsg="请填写其它原因"></textarea>
				<span class="Validform_checktip"></span>
			</td>
		</tr>
	</table>
</t:formvalid>
</body>
